﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BiliBiliCSharpStudy.old {
    class EventDemo04 {
        public static void Demo() {
            Test1();
        }
        public static void Test1() {
            MyForm2 form = new MyForm2();
            form.ShowDialog();
        }
    }

    class MyForm2 : Form {
        private TextBox textBox;
        private Button button;
        public MyForm2() {
            this.textBox = new TextBox();
            this.button = new Button();
            this.Controls.Add(this.button);
            this.Controls.Add(this.textBox);
            this.button.Click += this.ButtonClicked;
            this.button.Text = "click me";
            this.button.Top = 100;
        }

        private void ButtonClicked(object sender, EventArgs e) {
            this.textBox.Text = DateTime.Now.ToString();
        }
    }
}
